#!/bin/bash

PROCESS_1="ToRedis.py"
PROCESS_2="DownLoader.py"

CMD_1="nohup python3 -u /home/zuo/25_OA自动化下载/Task/ToRedis.py > /home/zuo/25_OA自动化下载/Task/ToRedis.out 2>&1"
CMD_2="nohup python3 -u /home/zuo/25_OA自动化下载/Task/DownLoader.py >/home/zuo/25_OA自动化下载/Task/DownLoader.log 2>&1"

check_and_start() {
    local process_name=$1
    local command=$2

    if pgrep -f "$process_name" > /dev/null; then
        echo "$process_name 正在运行中..."
    else
        echo "$process_name 未运行，正在启动..."
        eval "$command"
        echo "$process_name 已启动。"
    fi
}

check_and_start "$PROCESS_1" "$CMD_1"
check_and_start "$PROCESS_2" "$CMD_2"
